package sii.fb.emotion.bean;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;

public class User {
	Long id;
	String name;
	String gender;
	Date birtday;
	String hometown;
	String[] personality;
	
	public String[] getPersonality() {
		return personality;
	}
	public void setPersonality(String[] personality) {
		this.personality = personality;
	}
	public void setBirtday(Date birtday) {
		this.birtday = birtday;
	}
	LinkedList<Post> posts;
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getGender() {
		return gender;
	}
	public void setGender(String gender) {
		this.gender = gender;
	}
	public Date getBirtday() {
		return birtday;
	}
	public void setBirtday(String date) {
		DateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
		DateFormat formatter1 = new SimpleDateFormat("MM/dd");
		if(date.equals("undefined"))
			this.birtday = null;
		else{
			try {
				this.birtday = formatter.parse(date);
			}catch (ParseException e) {
				try {
					this.birtday = formatter1.parse(date);
				} catch (ParseException e1) {
					e1.printStackTrace();
				}
			}
		}
	}
	public String getHometown() {
		return hometown;
	}
	public void setHometown(String hometown) {
		this.hometown = hometown;
	}
	public LinkedList<Post> getPosts() {
		return posts;
	}
	public void setPosts(LinkedList<Post> posts) {
		this.posts = posts;
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		User other = (User) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}
	@Override
	public String toString() {
		return "User [id=" + id + ", name=" + name + ", gender=" + gender
				+ ", birtday=" + birtday + ", hometown=" + hometown
				+ ", posts=" + posts + "]";
	}
		

}
